from case.start_appium import get_driver

driver = get_driver()
# 获取屏幕的宽高
def get_size():
    size = driver.get_window_size()  # 获取屏幕的width和height
    width = size['width']
    height = size['height']
    return width,height
# 向左滑动
def swipe_left():
    x1 = get_size()[0]/10*9
    y1 = get_size()[1]/2
    x = get_size()[0]/10
    driver.swipe(x1,y1,x,y1,)
# 向右滑动
def swipe_right():
    x1 = get_size()[0]/10*9
    y1 = get_size()[1]/2
    x = get_size()[0]/10
    driver.swipe(x,y1,x1,y1)
# 向上滑动
def swipe_up():
    x1 = get_size()[0]/2
    y1 = get_size()[1]/10*9
    y = get_size()[1]/10
    driver.swipe(x1,y1,x1,y)

# 向下滑动
def swipe_down():
    x1 = get_size()[0]/2
    y1 = get_size()[1]/10*9
    y = get_size()[1]/10
    driver.swipe(x1,y,x1,y1,)

def swipe_on(diretion):
    if diretion == 'left':
        swipe_left()
    elif diretion == 'right':
        swipe_right()
    elif diretion == 'up':
        swipe_up()
    else:
        swipe_down()
